import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DomWarRankInfo } from "./DomWarRankInfo";
import { SDominionPlayerScore } from "../../../../../Message/Public/SDominionPlayerScore";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTextFormat } from "../../../../common/GTextFormat";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { NameRule } from "../../../scene/player/entity/rule/NameRule";
//class DomWarRankCellRenderer
    
    export  class DomWarRankCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */createUI(): void
        {
            this._rankTxt = this.getCategoryTxt("", 0, 0);
            this._nameTxt = this.getCategoryTxt("", 48, 0);
            this._nameTxt.width = 232;
            this._nameTxt.autoSize = "center";
            this._capTxt = this.getCategoryTxt("", 296, 0);
            this._scoreTxt = this.getCategoryTxt("", 375, 0);
            this._scoreTxt.width = 64;
            this._scoreTxt.autoSize = "center";
            ObjCreate.createBg(0, 22, 465, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */get rankInfo(): DomWarRankInfo
        {
            return this._data as DomWarRankInfo;
        }

        /* internal  */get scoreInfo(): SDominionPlayerScore
        {
            if (this.rankInfo) 
            {
                return this.rankInfo.scoreInfo as SDominionPlayerScore;
            }
            return null;
        }

        /* internal  */getCategoryTxt(arg1: string="", arg2: number=0, arg3: number=0): GTextFiled
        {
            var loc2=null;
            var loc1=new GTextFormat(null, 14, 65280);
            (loc2 = ObjCreate.createGTextField(arg1, arg2, arg3, 100, 25, this, loc1)).autoSize = "left";
            loc2.mouseEnabled = false;
            return loc2;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            if (arg1 == null) 
            {
                return;
            }
            super.data = arg1;
            if (!this._isCreateUI) 
            {
                this._isCreateUI = true;
                this.createUI();
            }
            if (this.rankInfo) 
            {
                loc1 = this.scoreInfo.entityId;
                loc2 = EntityUtil.getProxyNameByProxyAndServer(loc1.typeEx2, loc1.typeEx);
                this._nameTxt.text = loc2 + this.scoreInfo.name;
                this._capTxt.text = NameRule.getDominionForceName(this.scoreInfo.force);
                this._rankTxt.text = this.rankInfo.rank.toString();
                this._scoreTxt.text = this.rankInfo.outPutValue.toString();
            }
            return;
        }

        /* internal */ /* var */_rankTxt: GTextFiled;

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_capTxt: GTextFiled;

        /* internal */ /* var */_scoreTxt: GTextFiled;

        /* internal */ /* var */_isCreateUI: Boolean=false;
    }
